<?PHP
#
# author: Cody Sorgenfrey with Jason Sanchez
# (c) 2012 Casa De Bendicion
#

include_once("mysql/mysqlCommon.php");
include_once("mysql/mysqlDB.php");

function sf_menu_element($nav, $t, $e) 
{
  printf("\t<li class='nav' >\n");	
  if (is_null($e)) {
    if (strpos($t[1], "ttp://") || strpos($t[1], ".pdf")) {
      printf("\t\t\t<a class='nav%d' href='%s' target='_blank'>%s</a>\n", $nav, $t[1], $t[0]);
    } else {
      printf("\t\t\t<a class='nav%d' href='%s'>%s</a>\n", $nav, $t[1], $t[0]);
    }
    printf("\t</li>\n");
    return;
  }
  printf("\t\t<a class='nav%d' href='#'>%s</a>\n", $nav, $t[0]);
  printf("\t\t<ul class='subnav'>\n");
  for ($i = 0; $i < sizeof($e); $i++) {
	  	printf("\t\t\t<li>\n");
		if (strpos($e[$i][1], "ttp://") || strpos($e[$i][1], ".pdf")) {
	    printf("\t\t\t\t<a class='menu' href='%s' target='_blank'>%s</a>\n", $e[$i][1], $e[$i][0]);
		} else {
	    printf("\t\t\t\t<a class='menu' href='%s'>%s</a>\n", $e[$i][1], $e[$i][0]);
		}
		printf("\t\t\t</li>\n");
  }
	printf("\t\t</ul>\n");
	printf("\t</li>\n");
}

function sf_menu() 
{
	printf("<div class='menuBar'>\n");
	printf("<ul class='sf-menu' id='nav'>\n");
	$title = array(
		array("THE STORY&nbsp;&nbsp;", "story.php"),
		array("ABOUT", "#"),
		array("SUPPORT", "support.php"),
		array("MEDIA", "media.php"),
		array("CONTACT", "contact.php"),
		array("BLOG", "http://blog.thehouseofblessing.org"),
		);
	$elements = array(
		NULL,
		array(array("<h6 style='color: #1D97C3; font-size:100%;'>BELIEFS</h6>","beliefs.php"),array("<h6 style='color: #1D97C3;font-size:100%;'>DIRECTOR</h6>","director.php"),array("<h6 style='color: #1D97C3; font-size:100%;'>BOARD OF DIRECTORS</h6>","bod.php")),  
		NULL,
		NULL,
		array(array("<h6 style='color: #1D97C3;font-size:100%;'>CONTACT US</h6>", "contact.php"), array("<h6 style='color: #1D97C3;font-size:100%;'>FACEBOOK</h6>", "http://www.facebook.com/bachinivaorphanage")),
		NULL
		);
	for ($i=0; $i < count ($title); $i++) {
		sf_menu_element($i+1, $title[$i], $elements[$i]);
	}
	printf("</ul>\n");
	printf("</div>\n");
}

function printMenu()
{
	if (userIsIE()){
		printf("<div class='pageMenu'>\n");
		printf("<table id='title'><tr><td id='mainTitle'><div id='title'><a href='/index.php'><h1 id='title'>CASA DE BENDICION</h1></a></div></td><td><div id='titleRight'><h6 id='title'>I will not leave you orphans; I will come to you.</br>John 14:18</h6></div></td></tr><tr><td><div><h2 id='subTitle' style='margin-top:-5px;'>house of blessing</h2></div></td><td></td></tr></table>\n");
		printf("\n");
		sf_menu();
		printf("</div>");
	} else{
		printf("<div class='pageMenu'>\n");
		printf("<table id='title'><tr><td id='mainTitle'><div id='title'><a href='/index.php'><h1 id='title'>CASA DE BENDICION</h1></a></div></td><td><div id='titleRight'><h6 id='title'>I will not leave you orphans; I will come to you.</br>John 14:18</h6></div></td></tr><tr><td><div><h2 id='subTitle'>house of blessing</h2></div></td><td></td></tr></table>\n");
		printf("\n");
		sf_menu();
		printf("</div>");
	}
}
function startPage($title, $metaKey, $metaDesc, $moreHtml, $moreJava, $printTitle)
{
	$YEAR = date(Y);
	printf("<!--\n");
	printf("#\n");
	printf("# (c)%s CASA DE BENDICION\n", $YEAR);
	printf("#\n");
	printf("-->\n");
	printf("<!DOCTYPE html>\n");
	printf("<html xmlns='http://www.w3.org/1999/xhtml'>\n");
	printf("\n");
	printf("<head>\n");
	printf("<title>Casa De Bendicion ~ %s</title>\n\n", $title);
	printf("<meta name='viewport' content='width=1375, minimum-scale=0.1 , maximum-scale=1'>");
	printf("<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>\n");
	printf("<meta name='keywords' content='Bachiniva, Mexico, Calvary, Chapel, South Hill Calvary Chapel, Washington, Church, Jason Sanchez, Orphans, Children, Kids, Charity, %s'/>\n", $metaKey);
	printf("<meta name='description' content='%s'/>\n", $metaDesc);
	printf("<meta name='content-type' content='text/html'/>\n");
	printf("<link href='css/main.css' rel='stylesheet' type='text/css'/>\n\n");
	printf("<link type='text/css' rel='stylesheet' href='http://www.southhillcalvary.org/js/superfish/css/superfishCasaDeBen.css' />\n");
	printf("<link type='text/css' rel='stylesheet' href='/js/galleryview-3.0b3/css/jquery.galleryview-3.0.css'/>\n");
	if ($moreHtml) printf("%s\n\n", $moreHtml);
	printf("<script type='text/javascript' src='http://www.southhillcalvary.org/js/jquery-1.4.2.min.js'></script>\n");
	printf("<script type='text/javascript' src='http://www.southhillcalvary.org/js/jquery.easing.1.3.js'></script>\n");
	printf("<script type='text/javascript' src='http://www.southhillcalvary.org/js/jquery.timers-1.2.js'></script>\n");
	printf("<script type='text/javascript' src='http://www.southhillcalvary.org/js/superfish/js/superfish.js'></script>\n");
	printf("<script type='text/javascript' src='http://www.southhillcalvary.org/js/superfish/js/hoverIntent.js'></script>\n");
	printf("<script type='text/javascript' src='http://www.southhillcalvary.org/js/superfish/js/supersubs.js'></script>\n");
	printf("<script type='text/javascript' src='/js/jquery-1.4.2.min.js'></script>\n");
	printf("<script type='text/javascript' src='/js/js.js'></script>\n");
	printf("<script type='text/javascript' src='/js/galleryview-3.0b3/js/jquery.galleryview-3.0.min.js'></script>\n");
	printf("<script type='text/javascript'> function goToPage(page) {window.location = 'http://www.thehouseofblessing.org/'+page;}</script>\n");
	//SUPERSUBS
	printf("<script type='text/javascript'>\n");
	printf("\tjQuery(function(){\n");
	printf("\t\tjQuery('ul.sf-menu').supersubs(\n");
	printf("\t\t\t{\n");
	printf("\t\t\tminWidth: 15,   // minimum width of sub-menus in em units\n");
	printf("\t\t\tmaxWidth: 15,   // maximum width of sub-menus in em units \n");
	printf("\t\t\textraWidth: 1,     // extra width can ensure lines don't sometimes turn over due to slight rounding differences and font-family\n");
	//printf("\t\t\dropShadows: false,\n");
	printf("\t\t\tautoArrows: true // if true, arrow mark-up generated automatically = cleaner source code at expense of initialisation performance\n");
	printf("\t\t\t}\n");
	printf("\t\t).superfish();\n");
	printf("\t});\n");
	//*/ 
	printf("</script>\n");
	if ($moreJava) printf("%s\n\n", $moreJava);
	printf("<script type='text/javascript'>
	  var _gaq = _gaq || [];
	  _gaq.push(['_setAccount', 'UA-34850825-1']);
	  _gaq.push(['_trackPageview']);
	  (function() {
	    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
	  })();
	</script>");
	printf("</head>\n");
	printf("<body>\n");
	printf("<div class='body'>\n");
	printf("<div class='pageContent'>\n");
	printMenu();
	if ($printTitle) printf("<h1 style='font-size:%s;'>%s...</h1>\n\n","250%", strtoupper($printTitle));
}

function printFooter()
{
	$YEAR=date(Y);
	printf("<div class='footer'><p>&#169; %s Casa De Bendicion ~ \n", $YEAR);
	printf("<a class='footer' href='mailTo:codys@thehouseofblessing.org?subject=%s'>Contact the Webservant</a></div>\n\n", "House%20of%20Blessing%20Website.");
}

function endPage()
{
	printFooter();
	printf("</div>\n");
	printf("</div>");
	printf("</body>\n");
	printf("</html>\n");
}

function mailingBox($marginTop){
	
	if ($marginTop) $margin = $marginTop;
	else $margin = "0px";
		return '<div class="mailingBox" style="margin-top:'.$margin.';">
				<div id="form">
				<form action="http://thehouseofblessing.us5.list-manage.com/subscribe/post?u=4bc1c926d2d7b27ac1203d019&amp;id=668c11cbc8" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
		<h6 id="mailingList">mailing list</h6>
		<input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email address" required><br><br>
		<input type="name" value="" name="FNAME" class="email" id="mce-EMAIL" placeholder="name" required><br><br>
		<input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">
		</form>
		</div>
		
		<!--End mc_embed_signup-->
			
		</div>
		</div>';
}

function mainBox($paragraph, $id, $margin){

	return "<div class='".$id."' style='margin-top:".$margin.";'>\n
			<p id='mainParagraph'>".$paragraph."</p><br>\n
			</div>\n\n";
}

function verseBox($marginTop, $ref, $text, $id){

	return "<div class='".$id."' style='margin-top:".$marginTop."'>\n
			<p id='verseParagraph'>".$text."</p>\n
			<p id='verseRef'>".$ref."</p>\n
			</div>\n\n";
}

function userIsApple() {

$agent = $_SERVER['HTTP_USER_AGENT'];

$var[0] = 'iPhone';
$var[1] = 'iPad';
$var[2] = 'iPod';
$var[3] = 'Macintosh';

$result = count($var);

		for ($i=0;$i<$result;$i++){  
		  
			$ausg = stristr($agent, $var[$i]);  
			if(strlen($ausg)>0){
				
				return TRUE;
				exit;
				
			}
		}

}

function userIsIE() {

	$agent = $_SERVER['HTTP_USER_AGENT'];

	$ausg = stristr($agent, "MSIE");  
		
		if(strlen($ausg)>0){
			
			return TRUE;
			
			exit;
			}
}

function printPageTable($first, $second, $third, $fourth){
	
	printf("<table id='page'><tr><td>\n\n");
	
	printf("%s\n\n", $first);
	
	printf("</td><td>\n\n");
	
	printf("%s\n\n", $second);
	
	printf("</td></tr><tr><td style='height:10px;'><td></td></td></tr><tr><td>\n\n");
	
	printf("%s\n\n", $third);
	
	printf("</td><td>\n\n");
	
	printf("%s\n\n", $fourth);
	
	printf("</td></tr></table>\n\n");
}

function printFacebookBanner(){
	
	printf("<div id='facebookBanner'><a href='http://www.facebook.com/bachinivaorphanage'><img style='width:175px;' src='/images/FB.png'></img></a></div>", "-3%", "-2%");
}

?>